using Pvp.Ecs;

namespace Pvp
{
    /// <summary>
    /// 门机关2： 需要玩家手动触发
    /// </summary>
    [EntityDeclare((int)EntityType.gear, (int) GearType.门机关2)]
    class EntityDeclare1642 :BaseEntityDeclare
    {
        private IUnitInteractive m_UnitInteractive;
        private IView m_View;
        public override void OnEntityCreate(Entity entity,object userData)
        {
            m_View = entity.AddComponent<IView>();
            entity.AddComponent<IUnit>();
            m_UnitInteractive = entity.AddComponent<IUnitInteractive>();
            var gear =  entity.AddComponent<IGearUnit>();
            gear.GearOpenTrigger = OnOpen;
        }

        private bool OnOpen(IGearUnit gear)
        {
            //某个玩家是否触发有效操作
            if (m_UnitInteractive == null)
                return false;
            return m_View.IsInView && m_UnitInteractive.currentActionFlag && m_UnitInteractive.currentInputType == 3;
        }
    }
}